const router = require('koa-router')();
const { redis } = require('../../config/env');
const RedisStore = require('koa-redis')(redis);

router.all('/', async (ctx, next) => {        //登出逻辑
    let session_id = ctx.cookies.get('session_id');
    ctx.session.logged = false;
    let sess = RedisStore.get(session_id);
    let result = await RedisStore.destroy(session_id);      //销毁内存中session,于登录时重新存入
    ctx.type = 'application/json';
    ctx.body = {
        code: 0,
        msg: '退出登录'
    }
});

module.exports = router.routes();